package com.itheima.mapper;

import com.itheima.domain.Student;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface StudentMapper {

    /**
     * 查询所有
     * @return
     */
    @Select("select * from student")
    List<Student> findAll();

    /**
     * 根据id查询
     * @param id
     * @return
     */
    @Select("select * from student where id = #{id}")
    Student findById(String id);

    /**
     * 保存
     * @param student
     */
    @Insert("insert into student(id,name,birthday,address)values(#{id},#{name},#{birthday},#{address})")
    void save(Student student);

    /**
     * 更新
     * @param student
     */
    @Update("update student set name=#{name},birthday=#{birthday},address=#{address} where id =#{id}")
    void update(Student student);

    /**
     * 删除
     * @param id
     */
    @Delete("delete from student where id = #{id}")
    void delete(String id);
}
